package org.hi.trip.service.impl;

import java.sql.SQLException;
import java.util.List;

import org.apache.struts2.util.DateFormatter;
import org.hi.framework.paging.PageInfo;
import org.hi.trip.dao.TripDAO;
import org.hi.trip.model.Trip;
import org.hi.framework.service.impl.ManagerImpl;
import org.hi.trip.service.TripManager;
import org.hi.util.StringUtil;

public class TripManagerImpl extends ManagerImpl implements TripManager{
    
    protected void preSaveObject(Object obj) {
        super.preSaveObject(obj);

    }

    protected void postSaveObject(Object obj) {
        super.postSaveObject(obj);

    }

    protected void preRemoveObject(Object obj) {
        super.preRemoveObject(obj);
        
    }

    protected void postRemoveObject(Object obj) {
        super.postRemoveObject(obj);
        
    }
    
    public void saveTrip(Trip trip){
    	
    	if(StringUtil.isEmpty(trip.getTrip_code())) {
	    	String tripCode = "";
	    	tripCode = trip.getTrip_model().getTrip_code() + StringUtil.getFormattedStringByDate(trip.getTrip_date(), null);
	    	trip.setTrip_code(tripCode);
    	}
    	
    	saveObject(trip);
    
    }

    public void removeTripById(Integer id){
    	removeObjectById(id);
    	
    }

    public Trip getTripById(Integer id){
   		return (Trip) getObjectById(id);
    }

    public List<Trip> getTripList(PageInfo pageInfo){
    	return super.getList(pageInfo);
    }

    public void saveSecurityTrip(Trip trip){
    	saveObject(trip);
    
    }

    public void removeSecurityTripById(Integer id){
    	removeObjectById(id);
    	
    }

    public Trip getSecurityTripById(Integer id){
   		return (Trip) getObjectById(id);
    }

    public List<Trip> getSecurityTripList(PageInfo pageInfo){
    	return super.getList(pageInfo);
    }

  
}
